using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.IO;

namespace DaphneTranslator.BusinessLogic
{
	public class FileFinder
	{
		List<string> _lstFiles = new List<string>();		
		
		public FileFinder ()
		{
		}
		
		public List<string> EnumerateFiles (string sPath, List<string> lstSearchPatterns)
		{
			EnumerateFilesInDir (sPath, lstSearchPatterns);
			return _lstFiles;
		}
		
		private void EnumerateFilesInDir (string sPath, List<string> lstSearchPatterns)
		{
			// look for files
			foreach (string sSearchPattern in lstSearchPatterns) {
				string[] arrFiles = Directory.GetFiles (sPath, sSearchPattern);
				_lstFiles.AddRange (arrFiles);
			}
			
			// look for subdirectories
			string[] arrDirectories = Directory.GetDirectories (sPath);
			foreach (string sDirectory in arrDirectories) {
				EnumerateFilesInDir (sDirectory, lstSearchPatterns);
			}
		}
	}
}
			